import java.util.Arrays;

public class Solution1184 {
    public int distanceBetweenBusStops(int[] distance, int start, int destination) {
        int sum=0;
        for (int i=Math.min(start,destination);i<Math.max(start,destination);i++){
            sum+=distance[i];
        }
        return Math.min(sum, Arrays.stream(distance).sum()-sum);
    }

    public static void main(String[] args) {
        System.out.println(new Solution1184().distanceBetweenBusStops(new int[]{1,2,3,4},0,1));
    }
}
